using System.Collections.Generic;
using System.Xml;

namespace DbBuilder
{
	public class ChangeLog : SortedList<string, ScriptList>
	{
		public string LatestBuildNumber { get; private set; }

		public ChangeLog(string fileName)
		{
			XmlDocument xml = new XmlDocument();
			xml.Load(fileName);
			foreach (XmlNode buildNode in xml.SelectNodes("//Builds/Build"))
			{
				string buildNumber = buildNode.Attributes["Number"].Value;
				ScriptList entry = new ScriptList(buildNode.SelectNodes("Step"));
				Add(buildNumber, entry);
				if (string.Compare(buildNumber, LatestBuildNumber) > 0)
				{
					LatestBuildNumber = buildNumber;
				}
			}
		}
	}
}